# 调用父类的方法   用super
# class A:
#     def smoke(self):
#         print('A.吸烟')
#     def drink(self):
#         print('A.喝酒')
# class B(A):
#     def smoke(self):
#         print('B.吸烟')
#     def do_something(self):
#         super().smoke() 直接调父类的方法
# b = B()
# b.smoke()
# A.smoke(b)
# super(B,b).smoke()
#
# #    判断一个类是否属于其他类的子类  (zi   fu)
# issubclass(cls,class_or_tuple)
# getattr hasattr setattr delattr

# class Dog:
#     pass
# d = Dog()
# d.color = 'red'
# d.age = 18
# print(d.color)
# k = getattr(d,'color')
# print(k)
# print(hasattr(d,'age'))
# setattr(d,'kind',33)
# print(d.kind)
# delattr(d,'age')
# print(d.age)

class MyMatris:
    def __init__(self, matrix_data):
        self.data = matrix_data
    def __str__(self):
        l1 = []
        for line in self.data:
            line = ' '.join([str(x) for x in line])  # ['1','2','3']   1 2 3
            line = '| ' + line + ' |'
            l1.append(line)
        return '\n'.join(l1)
    def add(self, other):
        result = []
        for row_index in range(len(self.data)):
            inner_result = []
            for col_index in range(len(self.data[row_index])):
                number = self.data[row_index][col_index]+other.data[row_index][col_index]
                inner_result.append(number)
            result.append(inner_result)
        return result

m1 = MyMatris([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
m2 = MyMatris([[10, 20, 30], [40, 50, 60], [70, 80, 90]])
print(m1)
print(m2)
m3 = m1.add(m2)
print(m3)
